const initialState = {
  1: {
    id: 1,
    url:
      'https://s3.ap-northeast-1.amazonaws.com/test.molartech/fxHW2jgIRr15866867922946141.jpg',
    size: {
      width: '1080px',
      height: '720px',
    },
  },
  2: {
    id: 2,
    url:
      'https://s3.ap-northeast-1.amazonaws.com/test.molartech/GblC0LTZkP15866869447402212.jpg',
    size: {
      width: '1080px',
      height: '720px',
    },
  },
  3: {
    id: 3,
    url:
      'https://s3.ap-northeast-1.amazonaws.com/test.molartech/ia6WgC0HDV15866869673275063.jpg',
    size: {
      width: '1080px',
      height: '720px',
    },
  },
  4: {
    id: 4,
    url:
      'https://s3.ap-northeast-1.amazonaws.com/test.molartech/wvMWRS5jOp15866869880194554.jpg',
    size: {
      width: '1080px',
      height: '720px',
    },
  },
};

export const CarouselActions = {
  CAROUSEL_UPDATE: 'carousel_update',
  CAROUSEL_RESET: 'carousel_reset',
};

export function updateCarousel(payload) {
  return {
    type: CarouselActions.CAROUSEL_UPDATE,
    payload,
  };
}

export function resetCarousel() {
  return {
    type: CarouselActions.CAROUSEL_UPDATE,
  };
}

export default function carousel(state = initialState, action) {
  switch (action.type) {
    case CarouselActions.INTL_UPDATE:
      return {...state, [action.payload.id]: action.payload};
    case CarouselActions.CAROUSEL_RESET:
      return initialState;
    default:
      return state;
  }
}
